package cn.bx.bid.service;

import cn.bx.bid.entity.Answer;
import cn.bx.bid.entity.Question;
import cn.bx.bid.repository.AnswerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Optional;

@Service
@Transactional(readOnly = false)
public class AnswerService {
    @Autowired
    private AnswerRepository answerRepository;


    public int save(Answer answer) {
        answerRepository.save(answer);
        return 1;
    }

    public Answer get(long id) {
        Optional<Answer> findById = answerRepository.findById(id);
        return findById.get();
    }


}
